﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZX.OA.Model;

namespace ZX.OA.DAL
{
    /// <summary>
    /// 会议表的操作
    /// </summary>
  public   class MeetingDal
    {
    
          /// <summary>
          /// EF的链接
          /// </summary>
          Entity entity = new Entity();
          /// <summary>
          /// 会议表的显示
          /// </summary>
          /// <returns></returns>
          public List<MeetingInfo> Show_MeetingInfo()
          {
              return entity.MeetingInfo.ToList();
          }
          /// <summary>
          /// 会议室下拉框显示
          /// </summary>
          /// <returns></returns>
          public List<MeetingRoomInfo> Drop_MeetingRoomInfo()
          {
              return entity.MeetingRoomInfo.ToList();
          }
          /// <summary>
          /// 添加会议信息
          /// </summary>
          /// <param name="id"></param>
          /// <returns></returns>
          public int Add_MeetingInfo(MeetingInfo meeting)
          {
              entity.MeetingInfo.Add(meeting);
              return entity.SaveChanges();
          }
          /// <summary>
          /// 显示会议详情
          /// </summary>
          /// <param name="id"></param>
          /// <returns></returns>
          public MeetingInfo Upd_MeetingInfo(int id)
          {
              return entity.MeetingInfo.Find(id);
          }
          /// <summary>
          /// 撤销会议信息
          /// </summary>
          /// <param name="id"></param>
          /// <returns></returns>
          public int Del_MeetingInfo(int id)
          {
              entity.MeetingInfo.Remove(entity.MeetingInfo.Find(id));
              return entity.SaveChanges();

          }
         /// <summary>
         /// 多条件查询会议
         /// </summary>
         /// <param name="MeetingName">会议名</param>
         /// <param name="MeetingPerson">发起人</param>
         /// <param name="MeetingRoom">会议室</param>
         /// <returns></returns>
         public List<MeetingInfo> Sel_MeetingInfo (string MeetingName,string MeetingPerson,int ? MeetingRoomId)
         {
             return entity.MeetingInfo.Where(p => (string.IsNullOrEmpty(MeetingName) ? true : p.MeetingName.Contains(MeetingName)) || (string.IsNullOrEmpty(MeetingPerson) ? true : p.MeetingPerson.Contains(MeetingPerson)) || (p.MeetingRoomId == null ? true : p.MeetingRoomId == MeetingRoomId)).ToList();
         }
    

     
    }
}
